import yaml
import logging

def read_config(filename,name):
    try:
        # 打开YAML配置文件
        file_path = r'config/' + filename + '.yaml'
        with open(file_path, 'r', encoding='utf-8') as file:
            # 使用yaml.safe_load()加载配置文件内容
            configs = yaml.safe_load(file)
            config=configs[f'{name}']
        return config
    except FileNotFoundError:
        logging.error(f"配置文件未找到:{file_path}")
    except yaml.YAMLError as e:
        logging.error(f"YAML格式错误: {e}")

if __name__=='__main__':
    # read_config("cron1","job")
    # database=read_config("database","database")
    table=read_config("database","table")
    print(table)